package org.example.api;

import org.example.dto.TaskDataDTO;
import org.example.service.TaskDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ApiExample {

    @Autowired
    private TaskDataService taskDataService;

    @GetMapping("noCacheTest")
    public TaskDataDTO noCacheTest(String id){
        return taskDataService.getTaskDataDTO(id);
    }

    @GetMapping("haveCacheTest")
    public TaskDataDTO haveCacheTest(String id){
        return taskDataService.haveCacheTest(id);
    }

    @PostMapping("createTaskData")
    public void createTaskData(@RequestBody TaskDataDTO taskDataDTO){
        taskDataService.saveTaskData(taskDataDTO);
    }

}
